﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AppStore.Domain.Abstract;

namespace AppStore.Controllers
{
    public class StoreController : Controller
    {
        private IApplicationRepository _applicationRepository;
        private ICategoryRepository _categoryRepository;

        public StoreController(IApplicationRepository applicationRepository, ICategoryRepository categoryRepository)
        {
            _applicationRepository = applicationRepository;
            _categoryRepository = categoryRepository;
        }
        public ActionResult Index()
        {
            var apps = _applicationRepository.Applications;
            return View(apps);
        }

        [ChildActionOnly]
        public ActionResult CategoryMenu()
        {
            var categories = _categoryRepository.Categories.ToList();

            return PartialView(categories);
        }
        [ChildActionOnly]
        public ActionResult BestSellers()
        {
            var apps = _applicationRepository.Applications.OrderBy(a => a.counter).Take(4);

            return PartialView(apps);
        }
    }
}
